<?php
namespace App\Controllers;
use App\Controllers\Base;
use App\Libraries\LibComp;
use App\Libraries\LibMenu;
use App\Services\comm;
use CodeIgniter\Config\Services;
use http\Env\Request;

class Home extends Base
{
    function __construct(){
    }

    public function index(){
	    return $this->toJson('欢迎使用next-admin后台管理');
	}

	//--------------------------------------------------------------------
	public function main(){
        $this->actionAuth();
	    if(!$this->session->has('id')) {
	        return redirect()->to('login');
        }
        return $this->display(['view_path'=>'main']);
    }

    // 登录界面
    public function login(){
        if($this->session->has('id')) {
            return redirect()->to('main');
        }
        return view('_login3');
    }

    // 登出
    public function logout(){
	    $this->session->destroy();

        return redirect()->to('login');
    }



    // 图形验证码
    public function captcha(){
        \App\Libraries\LibComm::Captcha();
    }

    //
    public function layout(){
        return $this->display(['view_path'=>'main']);
    }

    public function sign(){
        return $this->toJson('登录成功');
    }

    public function test(){
        log_message('error',WRITEPATH);
        $str = base64_encode(file_get_contents('logo.png'));
        var_dump($str);

        $request = \Requests::post('url',[]);
    }

}
